package com.java.module.user.controller.admin;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.java.common.lang.annotation.Log;
import com.java.common.lang.domain.AjaxResult;
import com.java.common.lang.domain.page.TableDataInfo;
import com.java.common.lang.enums.BusinessTypeEnum;
import com.java.common.utils.WebKit;
import com.java.module.user.domain.Feedback;
import com.java.module.user.service.IFeedbackService;

/**
 * 意见反馈Controller
 * 
 * @author Administrator
 * @date 2021-04-25
 */
@RestController("AdminFeedbackController")
@RequestMapping("/user/feedback")
public class FeedbackController {

    @Autowired
    private IFeedbackService feedbackService;

    /**
     * 查询意见反馈列表
     */
    @PreAuthorize("@ss.hasPermi('user:feedback:list')")
    @GetMapping("/list")
    public TableDataInfo list(Feedback feedback) {
        WebKit.startPage();
        List<Feedback> list = feedbackService.selectFeedbackList(feedback);
        return WebKit.getDataTable(list);
    }

    /**
     * 获取意见反馈详细信息
     */
    @PreAuthorize("@ss.hasPermi('user:feedback:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(feedbackService.selectFeedbackById(id));
    }

    /**
     * 修改意见反馈
     */
    @PreAuthorize("@ss.hasPermi('user:feedback:edit')")
    @Log(title = "意见反馈", businessType = BusinessTypeEnum.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Feedback feedback) {
        return WebKit.toAjax(feedbackService.updateFeedback(feedback));
    }

    /**
     * 删除意见反馈
     */
    @PreAuthorize("@ss.hasPermi('user:feedback:remove')")
    @Log(title = "意见反馈", businessType = BusinessTypeEnum.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return WebKit.toAjax(feedbackService.deleteFeedbackByIds(ids));
    }

}
